home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / rlib / loaddir < prev    next >
Text File  |  1995-11-20  |  1KB  |  56 lines

  1. //-------------------------------------------------------------------//
  2. //
  3. //  Syntax:     loaddir ( DIRNAME )
  4. //
  5. //  Description:
  6. //
  7. //  An Acorn replacement for loaddir
  8. //
  9. //  loaddir loads all of the files in the directory DIRNAME. DIRNAME
  10. //  is a string identifying the directory of files to be loaded.
  11. //  Unfortunately, at the moment ALL FILES, not just r-files are loaded.
  12. //  Attempts to load a non r-file will cause an error and abort.
  13. //
  14. //  Example: 
  15. //  > loaddir ("adfs::4.$.Maths");    - Load all files from maths directory
  16. //  > loaddir (".");            - Load all files from CSD
  17. //
  18. //-------------------------------------------------------------------//
  19.  
  20. loaddir = function( dir )
  21. {
  22.     local(dir);
  23.     local(var1);
  24.     local(files);
  25.     local(i);
  26.     local(j);
  27.     i=0;
  28.     if(dir==".") 
  29.     {
  30.         dir="";
  31.     else
  32.         dir=dir+".";
  33.     }
  34.     // Use OS to produce a directory listing
  35.     system("info "+dir+"* { > "+dir+"mycat }");
  36.     // Read through directory listing
  37.     while(1)
  38.     {
  39.         i++;
  40.         var1=getline(dir+"mycat");
  41.         if(length(var1)==0) {break;}
  42.         files[i]=var1.[1];
  43.     }
  44.     close(dir+"mycat");
  45.     // Delete the directory listing file
  46.     system("delete "+dir+"mycat");
  47.     // Print out the list of files to be read
  48.     files
  49.     for(j in 1:i-1)
  50.     {
  51.         // Don't load directory file (may still be there...)
  52.         if(files[j] != "mycat")
  53.         {  load(dir+files[j]);  }
  54.     }
  55. };
  56.